package com.dmlll.service.impl;

import com.dmlll.VO.InformationManagement;
import com.dmlll.VO.InformationManagementDTO;
import com.dmlll.dao.FamilyPlanningMapper;
import com.dmlll.pojo.FamilyPlanning;
import com.dmlll.service.FamilyPlanningService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class FamilyPlanningServiceImpl implements FamilyPlanningService {
    @Autowired
    private FamilyPlanningMapper familyPlanningMapper;
    @Override
    public int insertsPlanning(FamilyPlanning familyPlanning){
        return familyPlanningMapper.insertSelective(familyPlanning);
    }
    //信息管理分页查
    @Override
    public PageInfo<InformationManagement> findAll(InformationManagementDTO informationManagementDTO,Integer pageNun, Integer Sice,Integer Grade){
        PageHelper.startPage(pageNun,Sice);
        List<InformationManagement> list=familyPlanningMapper.selectAll(informationManagementDTO,Grade);
        PageInfo<InformationManagement> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }
    //查询用户所在镇的code值
    @Override
    public int findGrade(Integer id){
        return familyPlanningMapper.selectGrade(id);
    }

    @Override
    public FamilyPlanning findFamilyPlanningById(Integer id) {
        return familyPlanningMapper.selectByPrimaryKey(id);
    }

    @Override
    public void updatePlanning(FamilyPlanning planning) {
        familyPlanningMapper.updateByPrimaryKeySelective(planning);
    }

}
